/*
 Navicat Premium Data Transfer

 Source Server         : mysql81
 Source Server Type    : MySQL
 Source Server Version : 80100 (8.1.0)
 Source Host           : localhost:3306
 Source Schema         : oracle

 Target Server Type    : MySQL
 Target Server Version : 80100 (8.1.0)
 File Encoding         : 65001

 Date: 03/12/2024 17:06:39
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for question_chapters
-- ----------------------------
DROP TABLE IF EXISTS `question_chapters`;
CREATE TABLE `question_chapters`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '章节ID',
  `subject_id` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '科目ID',
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '章节名称（如：线性表等）',
  `sort_order` int NOT NULL COMMENT '排序顺序，值越小越靠前',
  `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL COMMENT '章节描述',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci;

-- ----------------------------
-- Records of question_chapters
-- ----------------------------
BEGIN;
INSERT INTO `question_chapters` (`id`, `subject_id`, `name`, `sort_order`, `description`, `created_at`, `updated_at`) VALUES (1, '1', '绪论', 1, '绪论是课程的开篇部分，介绍基本概念和整体框架。', '2024-11-11 19:44:11', '2024-11-11 19:44:11'), (2, '1', '线性表', 2, '线性表是由有限个元素按一定顺序排列而成的数据结构。', '2024-11-11 19:44:52', '2024-11-11 19:44:52'), (3, '1', '栈与队列与数组', 3, '栈、队列和数组是常见的线性数据结构。', '2024-11-11 19:44:52', '2024-11-11 19:44:52'), (4, '1', '串', 4, '串是由一系列字符组成的数据结构，广泛应用于文本处理。', '2024-11-11 19:44:52', '2024-11-11 19:44:52'), (5, '1', '树与二叉树', 5, '树结构是一种分层数据结构，二叉树是树的一种特殊形式。', '2024-11-11 19:44:52', '2024-11-11 19:44:52'), (6, '1', '图', 6, '图是用于表示实体关系的数据结构，常用于表示网络、路线等。', '2024-11-11 19:44:52', '2024-11-11 19:44:52'), (7, '1', '查找', 7, '查找是指在数据结构中寻找指定元素的方法，如二分查找等。', '2024-11-11 19:44:52', '2024-11-11 19:44:52'), (8, '1', '排序', 8, '排序是将数据按某种规则排列的操作，常见的有冒泡排序、快速排序等。', '2024-11-11 19:44:52', '2024-11-11 19:44:52');
COMMIT;

-- ----------------------------
-- Table structure for questions
-- ----------------------------
DROP TABLE IF EXISTS `questions`;
CREATE TABLE `questions`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '题目ID',
  `subject_id` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '科目ID',
  `chapter_id` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '章节ID',
  `type` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '题目类型（如：选择题、填空题、简答题等）',
  `content` varchar(5000) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '题目内容',
  `answer` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '题目的答案',
  `options` json NULL COMMENT '选择题选项（使用JSON存储）',
  `difficulty` int NULL DEFAULT NULL COMMENT '难度等级（1-5级）',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `description` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '描述：真题/非真题',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci;

-- ----------------------------
-- Records of questions
-- ----------------------------
BEGIN;
INSERT INTO `questions` (`id`, `subject_id`, `chapter_id`, `type`, `content`, `answer`, `options`, `difficulty`, `created_at`, `updated_at`, `description`) VALUES (1, '1', '1', '选择题', '下列哪项是数据结构的基本概念？', 'A', '{\"A\": \"数据存储\", \"B\": \"计算机网络\", \"C\": \"操作系统\", \"D\": \"数据库\"}', 3, '2024-11-11 19:54:05', '2024-11-28 20:35:16', NULL), (2, '1', '1', '选择题', '栈的数据结构是如何操作的？', 'B', '{\"A\": \"先进先出\", \"B\": \"先进后出\", \"C\": \"后进后出\", \"D\": \"先进先出\"}', 3, '2024-11-11 19:54:05', '2024-11-28 20:35:16', NULL), (3, '1', '1', '选择题', '在数据结构中，链表与数组相比的主要优势是什么？', 'D', '{\"A\": \"快速查询\", \"B\": \"内存占用少\", \"C\": \"随机访问\", \"D\": \"动态大小\"}', 3, '2024-11-11 19:54:05', '2024-11-28 20:35:17', NULL), (4, '1', '1', '选择题', '下列哪个数据结构适合用于实现递归？', 'C', '{\"A\": \"栈\", \"B\": \"队列\", \"C\": \"树\", \"D\": \"图\"}', 3, '2024-11-11 19:54:05', '2024-11-28 20:35:18', NULL), (5, '1', '1', '选择题', '在二叉树中，节点的最大度数是多少？', 'A', '{\"A\": \"2\", \"B\": \"3\", \"C\": \"4\", \"D\": \"无限\"}', 3, '2024-11-11 19:54:05', '2024-11-28 21:26:22', NULL);
COMMIT;

-- ----------------------------
-- Table structure for subjects
-- ----------------------------
DROP TABLE IF EXISTS `subjects`;
CREATE TABLE `subjects`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '科目ID',
  `name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '科目名称（如：数据结构）',
  `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL COMMENT '科目的描述（可选）',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci;

-- ----------------------------
-- Records of subjects
-- ----------------------------
BEGIN;
INSERT INTO `subjects` (`id`, `name`, `description`, `created_at`, `updated_at`) VALUES (1, '数据结构', '这是408的数据结构科目', '2024-11-11 19:35:45', '2024-11-11 19:35:45'), (2, '操作系统', '操作系统科目，涉及计算机系统的基本原理与设计', '2024-11-13 20:13:13', '2024-11-13 20:13:13'), (3, '计算机组成原理', '计算机组成原理科目，讲解计算机硬件和系统架构', '2024-11-13 20:13:13', '2024-11-13 20:13:13'), (4, '计算机网络', '计算机网络科目，涵盖网络协议、传输层等知识', '2024-11-13 20:13:13', '2024-11-13 20:13:13');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
